#pragma once
#include <dsound.h>
#include <mmsystem.h>
#include "..\dxstdafx.h"
#include "..\base\Engine.h"
#include "AudioBuffer.h"
#include <map>

namespace ds {

class AudioBuffer;

class AudioManager {

struct AudioSound {
	IdString hash;
	char name[32];
	AudioBuffer* buffer;
};

typedef List<AudioSound> AudioBuffers;

public:
	AudioManager();
	~AudioManager(void);
	bool initialize(HWND hWnd);
	bool createAudioBuffer(const char* soundName);
	bool play(const char* soundName,int volume, bool looping);
	void stop(const char* soundName);
	bool isPlaying(const char* soundName);
	void debug();
private:
	AudioBuffer* findByName(const char* name);
	bool setPrimaryBufferFormat(DWORD dwPrimaryChannels,DWORD dwPrimaryFreq,DWORD dwPrimaryBitRate );
	bool m_Initialized;
	IDirectSound8* m_pDS;
	AudioBuffers m_AudioBuffers;

};

};

